package com.qr.controller;

import com.qr.factory.BeanFactory;
import com.qr.service.IAccountService;
import com.qr.service.impl.IAccountServiceImpl;

import javax.xml.namespace.QName;

/**
 * 工厂模式创建对象
 */
public class AccountController {
    public static void main(String[] args) {

        IAccountService accountService = (IAccountService) BeanFactory.getMap("accountService");
        //com.qr.service.impl.IAccountServiceImpl@7f31245a
        System.out.println(accountService);
        accountService.saveAccount();

        /*
        *   创建的对象是单例的
        *   com.qr.service.impl.IAccountServiceImpl@7f31245a
        *   com.qr.service.impl.IAccountServiceImpl@7f31245a
        *   com.qr.service.impl.IAccountServiceImpl@7f31245a
        *   com.qr.service.impl.IAccountServiceImpl@7f31245a
        *   com.qr.service.impl.IAccountServiceImpl@7f31245a
        */
        for (int i = 0; i < 5; i++) {
            IAccountService accountScope = (IAccountService) BeanFactory.getMap("accountService");
            System.out.println(accountScope);
        }
    }
}
